Add Python project base template#2
Merged
Merged
Conversation
hatchling reads the LICENSE file declared in pyproject.toml
(`license = { file = "LICENSE" }`) at build time. The builder stage
only had pyproject.toml and uv.lock, causing:
OSError: License file does not exist: LICENSE
https://claude.ai/code/session_01TiXyp1vCmxNP2ewP4s1TGH
hatchling reads both README.md and LICENSE at package build time
(declared in pyproject.toml as readme and license fields).
Split the builder stage into two steps following uv's recommended
Docker pattern:
1. uv sync --no-dev --no-install-project → external deps only
(cached layer; invalidated only when pyproject.toml/uv.lock change)
2. Copy README.md + LICENSE + src/, then uv sync --no-dev
→ builds and installs the project with all required files present
This also gives better layer caching: adding a dependency rebuilds
step 1, changing source only rebuilds step 2.
https://claude.ai/code/session_01TiXyp1vCmxNP2ewP4s1TGH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
devfor dev containers / testing,prodfor deployment) usingghcr.io/astral-sh/uvas basepyproject.tomlwith uv, Ruff, Mypy (strict), Pytest, Bandit, pip-audit configured in one filedevDockerfile target with non-rootdevuser, named.venvvolume, and auto-sync on createCLAUDE.mdAI context +.claude/commands/slash commands (/test,/lint,/security,/build)uv.lockcommitted for reproducible installsChanges reviewed and fixed before merge
pythonpath = ["src"]added to pytest config so barepytestworks without editable install"off"to defer entirely to the mypy extension (was"basic", inconsistent withstrict = truein mypy)addopts— passed explicitly in CI only, so localpytestruns aren't slowed by coverage every timeuv run banditscope=dev/scope=prod) to prevent the two build steps overwriting each other's cacheenable-cache: trueadded to allsetup-uvstepstargets = ["src"]removed from[tool.bandit](not a valid pyproject.toml key for bandit)devcompose service removed — it was just a pytest runner with a misleading nameuv syncremoved from thedevDockerfile stage — the.venvnamed volume always shadowed it;uv runauto-syncs on first use insteaddevuser(uid 1000) added to the dev stage; devcontainer now runs as non-rootLICENSEadded to the builder stage COPY so hatchling can read it duringuv sync --no-devwarn_return_any,warn_unused_configs) removed — already implied bystrict = trueTest plan
uv run pytestpasses locally afteruv sync --all-groupsdocker compose run --rm testruns the test suitehttps://claude.ai/code/session_01TiXyp1vCmxNP2ewP4s1TGH
Generated by Claude Code